package com.jinzheng.kafkacom.controller;
import com.jinzheng.kafkacom.commont.KafkaProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * kafka生产者发送消息
 */
@RestController
@RequestMapping("/kafkaPro")
public class KafkaProController {

    @Autowired
    private KafkaProducer kafkaProducer;

    @GetMapping("/hello/{topic}")
    public String hello(@PathVariable String topic, @RequestParam String message){
        System.out.println("------->测试生产者发送消息");
        kafkaProducer.sendMessageByTopic(topic,null,message);
        return "kafka消息已发送.";
    }


}
